//
//  LYContactTableViewCell.swift
//  WeChat
//
//  Created by mac on 2018/8/3.
//  Copyright © 2018年 RRC. All rights reserved.
//

import UIKit

class LYContactTableViewCell: UITableViewCell {

    var avatarImageView:UIImageView!
    var usernameLabel:UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        avatarImageView = UIImageView()
        self.addSubview(avatarImageView)
        avatarImageView.snp.makeConstraints { (make) in
            make.leading.equalTo(10)
            make.top.equalTo(9)
            make.width.height.equalTo(36)
        }
        
        usernameLabel = UILabel()
        usernameLabel.text = "你好"
        usernameLabel.textColor = UIColor.black
        usernameLabel.font = UIFont.systemFont(ofSize: 16)
        usernameLabel.textAlignment = .left
        self.addSubview(usernameLabel)
        usernameLabel.snp.makeConstraints { (make) in
            make.leading.equalTo(avatarImageView.snp.trailing).offset(10)
            make.trailing.equalTo(29)
            make.top.equalTo(9)
            make.height.equalTo(20)
            make.width.greaterThanOrEqualTo(32)
        }
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setCellContent(_ model:ContactModel){
        avatarImageView.ly_setImageWithURLString(model.avatarSmallURL, placeholderImage: LYAsset.Icon_avatar.image)
        usernameLabel.text = model.chinseName
    }
}
